package com.tengfei.api.user;

import com.tengfei.common.annotation.Anonymous;
import com.tengfei.common.core.domain.R;
import com.tengfei.main.index.domain.vo.BannerVo;
import com.tengfei.main.index.domain.vo.NoticeVo;
import com.tengfei.main.user.domain.vo.course.UserCourseVo;
import com.tengfei.main.user.service.IUserIndexService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author feige
 * @version v1.0
 * @date 2022-08-14-14:46
 * @description 普通用户课程端首页
 */

@RestController
@RequestMapping("/user/index")
@Api(value = "用户首页控制器", tags = {"用户首页模块"})
public class UserIndexController {

    @Resource
    private IUserIndexService indexService;

    @Anonymous
    @ApiOperation("首页轮播图")
    @GetMapping("/banner")
    public R<List<BannerVo>> getBannerList(@ApiParam("轮播图数量(默认为4)") @RequestParam(value = "size", defaultValue = "4")
                                                   Integer size) {
        return R.ok(indexService.getBannerList(size));
    }


    @Anonymous
    @ApiOperation("首页热门课程")
    @GetMapping("/hotCourse")
    public R<List<UserCourseVo>> getHotCourseList(@ApiParam("热门课程数量(默认为6)") @RequestParam(value = "size", defaultValue = "6")
                                                          Integer size) {
        return R.ok(indexService.getHotCourseList(size));
    }


    @Anonymous
    @ApiOperation("首页最新课程")
    @GetMapping("/newCourse")
    public R<List<UserCourseVo>> getNewCourseList(@ApiParam("最新课程数量(默认为6)") @RequestParam(value = "size", defaultValue = "6") Integer size) {
        return R.ok(indexService.getNewCourseList(size));
    }

    @Anonymous
    @ApiOperation("首页通知公告")
    @GetMapping("/notice")
    public R<List<NoticeVo>> getNoticeList(@ApiParam("通知公告数量(默认为6)") @RequestParam(value = "size", defaultValue = "6") Integer size,
                                           @ApiParam("通知/公告(1:通知,2:公告,null:两者都包含)") @RequestParam(value = "type", required = false) Integer type) {
        return R.ok(indexService.getNoticeList(size, type));
    }

}
